import Cookies from 'js-cookie'
import { logout1 } from '@/http/protocol'

const token = Cookies.get('_ukey_age_')
// console.log(token)
// eslint-disable-next-line no-debugger
const user = {
  namespaced: true,
  state: {
    loginVisible: !token, //! token false
    rigieter: false,
    forget: false,
    loginS: !!token
  },
  mutations: {
    showlogin (state) {
      state.loginVisible = true
    },
    hidelogin (state) {
      state.loginVisible = false
    },
    showrigieter (state) {
      state.rigieter = true
    },
    hiddenrigieter (state) {
      state.rigieter = false
    },
    showforget (state) {
      state.forget = true
    },
    hideforget (state) {
      state.forget = false
    },
    setLoginS (state) {
      state.loginS = true
    },
    logout () {
      logout1()
      Cookies.remove('_ukey_age_', '/')
      setTimeout(() => {
        location.reload()
      }, 300)
    }

  },
  actions: {
    increment ({ commit }) {
      commit('showlogin')
    }
  },
  modules: {
  }
}

export default user
